using HKB.Common;
using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Web;
namespace HKB.OnLinePay
{
	public class AliPay : OnlinePay
	{
		private string siteurl;
		public string gateway = Convert.ToString(OnlinePay.Payconfig["AlipayGateWay"]);
		public string AlipayNotifyGateWay = Convert.ToString(OnlinePay.Payconfig["AlipayNotifyGateWay"]);
		public string return_url = "";
		public string notify_url = "";
		public string _input_charset = "utf-8";
		public string sign_type = "MD5";
		private NameValueCollection _coll = null;
		private string _out_trade_no;
		private string _trade_no;
		private string _subject;
		private string _body;
		private string _price;
		private bool _is_WAIT_BUYER_PAY = false;
		private bool _is_WAIT_SELLER_CONFIRM_TRADE = false;
		private bool _is_WAIT_SYS_CONFIRM_PAY = false;
		private bool _is_WAIT_SELLER_SEND_GOODS = false;
		private bool _is_WAIT_BUYER_CONFIRM_GOODS = false;
		private bool _is_WAIT_SYS_PAY_SELLER = false;
		private bool _is_TRADE_FINISHED = false;
		private bool _is_TRADE_CLOSED = false;
		private bool _is_INITIAL_STATUS = false;
		private bool _is_LOGISTICS_FAILURE = false;
		private bool _is_GOODS_RECEIVED = false;
		private bool _is_WAIT_RECEIVER_CONFIRM_GOODS = false;
		private bool _is_LOGISTICS_SENDING = false;
		private bool _is_WAIT_LOGISTICS_SEND_GOODS = false;
		private bool _is_WAIT_LOGISTICS_FETCH_GOODS = false;
		private bool _is_SEND_GOODS = false;
		private bool _is_REFUSE_FAST_PAY = false;
		private bool _is_MODIFY_TRADE = false;
		private bool _is_REFUSE_TRADE = false;
		private bool _is_QUERY_LOGISTICS = false;
		private bool _is_VIEW_DETAIL = false;
		private bool _is_EXTEND_TIMEOUT = false;
		private bool _is_QUERY_REFUND = false;
		private bool _is_PAY = false;
		private bool _is_MODIFY_DELIVER_ADDRESS = false;
		private bool _is_RM_PAY = false;
		private bool _is_FP_PAY = false;
		private bool _is_CANCEL_FAST_PAY = false;
		private bool _is_CONFIRM_GOODS = false;
		private bool _is_REFUND = false;
		private bool _is_Buyer_QUERY_LOGISTICS = false;
		private bool _is_Buyer_VIEW_DETAIL = false;
		private bool _is_Buyer_EXTEND_TIMEOUT = false;
		private bool _is_Buyer_QUERY_REFUND = false;
		private bool _is_WAIT_SELLER_AGREE = false;
		private bool _is_REFUND_CLOSED = false;
		private bool _is_REFUND_SUCCESS = false;
		private bool _is_OVERED_REFUND = false;
		private bool _is_ALIPAY_CHECK = false;
		private bool _is_WAIT_ALIPAY_REFUND = false;
		private bool _is_WAIT_SELLER_CONFIRM_GOODS = false;
		private bool _is_WAIT_BUYER_RETURN_GOODS = false;
		private bool _is_SELLER_REFUSE_BUYER = false;
		private string partner
		{
			get
			{
				string result;
				if (OnlinePay.Payconfig["AlipayConfig"].ToString().ToLower() == "system")
				{
					result = Convert.ToString(OnlinePay.Payconfig["AlipayPartnerID"]);
				}
				else
				{
					if (this.PartnerID == null)
					{
						result = Convert.ToString(OnlinePay.Payconfig["AlipayPartnerID"]);
					}
					else
					{
						result = this.PartnerID;
					}
				}
				return result;
			}
		}
		private string key
		{
			get
			{
				string result;
				if (OnlinePay.Payconfig["AlipayConfig"].ToString().ToLower() == "system")
				{
					result = Convert.ToString(OnlinePay.Payconfig["AlipayKey"]);
				}
				else
				{
					if (this.Key == null)
					{
						result = Convert.ToString(OnlinePay.Payconfig["AlipayKey"]);
					}
					else
					{
						result = this.Key;
					}
				}
				return result;
			}
		}
		public NameValueCollection coll
		{
			get
			{
				if (this._coll == null)
				{
					if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
					{
						this._coll = HttpContext.Current.Request.Form;
					}
					else
					{
						this._coll = HttpContext.Current.Request.QueryString;
					}
				}
				return this._coll;
			}
		}
		public string out_trade_no
		{
			get
			{
				this._out_trade_no = this.coll["out_trade_no"];
				return this._out_trade_no;
			}
		}
		public string trade_no
		{
			get
			{
				this._trade_no = this.coll["trade_no"];
				return this._trade_no;
			}
		}
		public string subject
		{
			get
			{
				this._subject = this.coll["subject"];
				return this._subject;
			}
		}
		public string body
		{
			get
			{
				this._body = this.coll["body"];
				return this._body;
			}
		}
		public string price
		{
			get
			{
				this._price = this.coll["price"];
				return this._price;
			}
		}
		public bool is_WAIT_BUYER_PAY
		{
			get
			{
				this._is_WAIT_BUYER_PAY = (this.coll["trade_status"] == "WAIT_BUYER_PAY");
				return this._is_WAIT_BUYER_PAY;
			}
		}
		public bool is_WAIT_SELLER_CONFIRM_TRADE
		{
			get
			{
				this._is_WAIT_SELLER_CONFIRM_TRADE = (this.coll["trade_status"] == "WAIT_SELLER_CONFIRM_TRADE");
				return this._is_WAIT_SELLER_CONFIRM_TRADE;
			}
		}
		public bool is_WAIT_SYS_CONFIRM_PAY
		{
			get
			{
				this._is_WAIT_SYS_CONFIRM_PAY = (this.coll["trade_status"] == "WAIT_SYS_CONFIRM_PAY");
				return this._is_WAIT_SYS_CONFIRM_PAY;
			}
		}
		public bool is_WAIT_SELLER_SEND_GOODS
		{
			get
			{
				this._is_WAIT_SELLER_SEND_GOODS = (this.coll["trade_status"] == "WAIT_SELLER_SEND_GOODS");
				return this._is_WAIT_SELLER_SEND_GOODS;
			}
		}
		public bool is_WAIT_BUYER_CONFIRM_GOODS
		{
			get
			{
				this._is_WAIT_BUYER_CONFIRM_GOODS = (this.coll["trade_status"] == "WAIT_BUYER_CONFIRM_GOODS");
				return this._is_WAIT_BUYER_CONFIRM_GOODS;
			}
		}
		public bool is_WAIT_SYS_PAY_SELLER
		{
			get
			{
				this._is_WAIT_SYS_PAY_SELLER = (this.coll["trade_status"] == "WAIT_SYS_PAY_SELLER");
				return this._is_WAIT_SYS_PAY_SELLER;
			}
		}
		public bool is_TRADE_FINISHED
		{
			get
			{
				this._is_TRADE_FINISHED = (this.coll["trade_status"] == "TRADE_FINISHED");
				return this._is_TRADE_FINISHED;
			}
		}
		public bool is_TRADE_CLOSED
		{
			get
			{
				this._is_TRADE_CLOSED = (this.coll["trade_status"] == "TRADE_CLOSED");
				return this._is_TRADE_CLOSED;
			}
		}
		public bool is_INITIAL_STATUS
		{
			get
			{
				this._is_INITIAL_STATUS = (this.coll["trade_status"] == "INITIAL_STATUS");
				return this._is_INITIAL_STATUS;
			}
		}
		public bool is_LOGISTICS_FAILURE
		{
			get
			{
				this._is_LOGISTICS_FAILURE = (this.coll["trade_status"] == "LOGISTICS_FAILURE");
				return this._is_LOGISTICS_FAILURE;
			}
		}
		public bool is_GOODS_RECEIVED
		{
			get
			{
				this._is_GOODS_RECEIVED = (this.coll["trade_status"] == "GOODS_RECEIVED");
				return this._is_GOODS_RECEIVED;
			}
		}
		public bool is_WAIT_RECEIVER_CONFIRM_GOODS
		{
			get
			{
				this._is_WAIT_RECEIVER_CONFIRM_GOODS = (this.coll["trade_status"] == "WAIT_RECEIVER_CONFIRM_GOODS");
				return this._is_WAIT_RECEIVER_CONFIRM_GOODS;
			}
		}
		public bool is_LOGISTICS_SENDING
		{
			get
			{
				this._is_LOGISTICS_SENDING = (this.coll["trade_status"] == "LOGISTICS_SENDING");
				return this._is_LOGISTICS_SENDING;
			}
		}
		public bool is_WAIT_LOGISTICS_SEND_GOODS
		{
			get
			{
				this._is_WAIT_LOGISTICS_SEND_GOODS = (this.coll["trade_status"] == "WAIT_LOGISTICS_SEND_GOODS");
				return this._is_WAIT_LOGISTICS_SEND_GOODS;
			}
		}
		public bool is_WAIT_LOGISTICS_FETCH_GOODS
		{
			get
			{
				this._is_WAIT_LOGISTICS_FETCH_GOODS = (this.coll["trade_status"] == "WAIT_LOGISTICS_FETCH_GOODS");
				return this._is_WAIT_LOGISTICS_FETCH_GOODS;
			}
		}
		public bool is_SEND_GOODS
		{
			get
			{
				this._is_SEND_GOODS = (this.coll["seller_actions"] == "SEND_GOODS");
				return this._is_SEND_GOODS;
			}
		}
		public bool is_REFUSE_FAST_PAY
		{
			get
			{
				this._is_REFUSE_FAST_PAY = (this.coll["seller_actions"] == "REFUSE_FAST_PAY");
				return this._is_REFUSE_FAST_PAY;
			}
		}
		public bool is_MODIFY_TRADE
		{
			get
			{
				this._is_MODIFY_TRADE = (this.coll["seller_actions"] == "MODIFY_TRADE");
				return this._is_MODIFY_TRADE;
			}
		}
		public bool is_REFUSE_TRADE
		{
			get
			{
				this._is_REFUSE_TRADE = (this.coll["seller_actions"] == "REFUSE_TRADE");
				return this._is_REFUSE_TRADE;
			}
		}
		public bool is_QUERY_LOGISTICS
		{
			get
			{
				this._is_QUERY_LOGISTICS = (this.coll["seller_actions"] == "QUERY_LOGISTICS");
				return this._is_QUERY_LOGISTICS;
			}
		}
		public bool is_VIEW_DETAIL
		{
			get
			{
				this._is_VIEW_DETAIL = (this.coll["seller_actions"] == "VIEW_DETAIL");
				return this._is_VIEW_DETAIL;
			}
		}
		public bool is_EXTEND_TIMEOUT
		{
			get
			{
				this._is_EXTEND_TIMEOUT = (this.coll["seller_actions"] == "EXTEND_TIMEOUT");
				return this._is_EXTEND_TIMEOUT;
			}
		}
		public bool is_QUERY_REFUND
		{
			get
			{
				this._is_QUERY_REFUND = (this.coll["seller_actions"] == "QUERY_REFUND");
				return this._is_QUERY_REFUND;
			}
		}
		public bool is_PAY
		{
			get
			{
				this._is_PAY = (this.coll["buyer_actions"] == "PAY");
				return this._is_PAY;
			}
		}
		public bool is_MODIFY_DELIVER_ADDRESS
		{
			get
			{
				this._is_MODIFY_DELIVER_ADDRESS = (this.coll["buyer_actions"] == "MODIFY_DELIVER_ADDRESS");
				return this._is_MODIFY_DELIVER_ADDRESS;
			}
		}
		public bool is_RM_PAY
		{
			get
			{
				this._is_RM_PAY = (this.coll["buyer_actions"] == "RM_PAY");
				return this._is_RM_PAY;
			}
		}
		public bool is_FP_PAY
		{
			get
			{
				this._is_FP_PAY = (this.coll["buyer_actions"] == "FP_PAY");
				return this._is_FP_PAY;
			}
		}
		public bool is_CANCEL_FAST_PAY
		{
			get
			{
				this._is_CANCEL_FAST_PAY = (this.coll["buyer_actions"] == "CANCEL_FAST_PAY");
				return this._is_CANCEL_FAST_PAY;
			}
		}
		public bool is_CONFIRM_GOODS
		{
			get
			{
				this._is_CONFIRM_GOODS = (this.coll["buyer_actions"] == "CONFIRM_GOODS");
				return this._is_CONFIRM_GOODS;
			}
		}
		public bool is_REFUND
		{
			get
			{
				this._is_REFUND = (this.coll["buyer_actions"] == "REFUND");
				return this._is_REFUND;
			}
		}
		public bool is_Buyer_QUERY_LOGISTICS
		{
			get
			{
				this._is_Buyer_QUERY_LOGISTICS = (this.coll["buyer_actions"] == "QUERY_LOGISTICS");
				return this._is_Buyer_QUERY_LOGISTICS;
			}
		}
		public bool is_Buyer_VIEW_DETAIL
		{
			get
			{
				this._is_Buyer_VIEW_DETAIL = (this.coll["buyer_actions"] == "VIEW_DETAIL");
				return this._is_Buyer_VIEW_DETAIL;
			}
		}
		public bool is_Buyer_EXTEND_TIMEOUT
		{
			get
			{
				this._is_Buyer_EXTEND_TIMEOUT = (this.coll["buyer_actions"] == "EXTEND_TIMEOUT");
				return this._is_Buyer_EXTEND_TIMEOUT;
			}
		}
		public bool is_Buyer_QUERY_REFUND
		{
			get
			{
				this._is_Buyer_QUERY_REFUND = (this.coll["buyer_actions"] == "QUERY_REFUND");
				return this._is_Buyer_QUERY_REFUND;
			}
		}
		public bool is_WAIT_SELLER_AGREE
		{
			get
			{
				this._is_WAIT_SELLER_AGREE = (this.coll["trade_status"] == "WAIT_SELLER_AGREE");
				return this._is_WAIT_SELLER_AGREE;
			}
		}
		public bool is_REFUND_CLOSED
		{
			get
			{
				this._is_REFUND_CLOSED = (this.coll["trade_status"] == "REFUND_CLOSED");
				return this._is_REFUND_CLOSED;
			}
		}
		public bool is_REFUND_SUCCESS
		{
			get
			{
				this._is_REFUND_SUCCESS = (this.coll["trade_status"] == "REFUND_SUCCESS");
				return this._is_REFUND_SUCCESS;
			}
		}
		public bool is_OVERED_REFUND
		{
			get
			{
				this._is_OVERED_REFUND = (this.coll["trade_status"] == "OVERED_REFUND");
				return this._is_OVERED_REFUND;
			}
		}
		public bool is_ALIPAY_CHECK
		{
			get
			{
				this._is_ALIPAY_CHECK = (this.coll["trade_status"] == "ALIPAY_CHECK");
				return this._is_ALIPAY_CHECK;
			}
		}
		public bool is_WAIT_ALIPAY_REFUND
		{
			get
			{
				this._is_WAIT_ALIPAY_REFUND = (this.coll["trade_status"] == "WAIT_ALIPAY_REFUND");
				return this._is_WAIT_ALIPAY_REFUND;
			}
		}
		public bool is_WAIT_SELLER_CONFIRM_GOODS
		{
			get
			{
				this._is_WAIT_SELLER_CONFIRM_GOODS = (this.coll["trade_status"] == "WAIT_SELLER_CONFIRM_GOODS");
				return this._is_WAIT_SELLER_CONFIRM_GOODS;
			}
		}
		public bool is_WAIT_BUYER_RETURN_GOODS
		{
			get
			{
				this._is_WAIT_BUYER_RETURN_GOODS = (this.coll["trade_status"] == "WAIT_BUYER_RETURN_GOODS");
				return this._is_WAIT_BUYER_RETURN_GOODS;
			}
		}
		public bool is_SELLER_REFUSE_BUYER
		{
			get
			{
				this._is_SELLER_REFUSE_BUYER = (this.coll["trade_status"] == "SELLER_REFUSE_BUYER");
				return this._is_SELLER_REFUSE_BUYER;
			}
		}
		public AliPay()
		{
			if (this.return_url == "" && this.notify_url == "")
			{
				this.siteurl = (OnlinePay.Payconfig["SiteUrl"].ToString().Contains("http://") ? OnlinePay.Payconfig["SiteUrl"].ToString() : ("http://" + OnlinePay.Payconfig["SiteUrl"].ToString()));
				this.return_url = this.siteurl + "/PayReturn/Alipay_Return.aspx";
				this.notify_url = this.siteurl + "/PayReturn/Alipay_Notify.aspx";
			}
		}
		public static string[] BubbleSort(string[] r)
		{
			for (int i = 0; i < r.Length; i++)
			{
				bool flag = false;
				for (int j = r.Length - 2; j >= i; j--)
				{
					if (string.CompareOrdinal(r[j + 1], r[j]) < 0)
					{
						string text = r[j + 1];
						r[j + 1] = r[j];
						r[j] = text;
						flag = true;
					}
				}
				if (!flag)
				{
					break;
				}
			}
			return r;
		}
		public static string GetMD5(string s, string _input_charset)
		{
			MD5 mD = new MD5CryptoServiceProvider();
			byte[] array = mD.ComputeHash(Encoding.GetEncoding(_input_charset).GetBytes(s));
			StringBuilder stringBuilder = new StringBuilder(32);
			for (int i = 0; i < array.Length; i++)
			{
				stringBuilder.Append(array[i].ToString("x").PadLeft(2, '0'));
			}
			return stringBuilder.ToString();
		}
		public string Get_Http(string a_strUrl, int timeout)
		{
			string result;
			try
			{
				HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(a_strUrl);
				httpWebRequest.Timeout = timeout;
				HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
				Stream responseStream = httpWebResponse.GetResponseStream();
				StreamReader streamReader = new StreamReader(responseStream, Encoding.Default);
				StringBuilder stringBuilder = new StringBuilder();
				while (-1 != streamReader.Peek())
				{
					stringBuilder.Append(streamReader.ReadLine());
				}
				result = stringBuilder.ToString();
			}
			catch (Exception ex)
			{
				ex.WriteErrorLog(new string[0]);
				result = "wrong";
			}
			return result;
		}
		public bool checkQurey()
		{
			string[] allKeys = this.coll.AllKeys;
			string[] array = AliPay.BubbleSort(allKeys);
			string text = "";
			for (int i = 0; i < array.Length; i++)
			{
				if (this.coll[array[i]] != "" && array[i] != "sign" && array[i] != "sign_type")
				{
					if (i == array.Length - 1)
					{
						text = text + array[i] + "=" + this.coll[array[i]];
					}
					else
					{
						text = string.Concat(new string[]
						{
							text,
							array[i],
							"=",
							this.coll[array[i]],
							"&"
						});
					}
				}
			}
			text += this.key;
			return AliPay.GetMD5(text, this._input_charset) == this.coll["sign"];
		}
		public bool CheckNote()
		{
			string a_strUrl = string.Concat(new string[]
			{
				this.AlipayNotifyGateWay,
				"service=notify_verify&partner=",
				this.partner,
				"&notify_id=",
				this.coll["notify_id"]
			});
			return this.Get_Http(a_strUrl, 120000) == "true";
		}
		private void inserPramList(string v, ArrayList a)
		{
			a.Add(v);
		}
		public string CreatUrl(string service, string out_trade_no, string subject, string body, string payment_type, string total_fee, string show_url, string seller_email, string seller_id, string quantity, string discount, string buyer_msg, string buyer_email, string buyer_id, string agent, string receive_name, string receive_address, string receive_zip, string receive_phone, string receive_mobile, string logistics_type, string logistics_fee, string logistics_payment, string logistics_type_1, string logistics_fee_1, string logistics_payment_1, string logistics_type_2, string logistics_fee_2, string logistics_payment_2)
		{
			ArrayList arrayList = new ArrayList(0);
			ArrayList arrayList2 = new ArrayList(0);
			if (!string.IsNullOrEmpty(service))
			{
				this.inserPramList("service=" + service, arrayList);
				this.inserPramList("service=" + service, arrayList2);
			}
			if (!string.IsNullOrEmpty(this.partner))
			{
				this.inserPramList("partner=" + this.partner, arrayList);
				this.inserPramList("partner=" + this.partner, arrayList2);
			}
			if (!string.IsNullOrEmpty(out_trade_no))
			{
				this.inserPramList("out_trade_no=" + out_trade_no, arrayList);
				this.inserPramList("out_trade_no=" + out_trade_no, arrayList2);
			}
			if (!string.IsNullOrEmpty(subject))
			{
				this.inserPramList("subject=" + subject, arrayList);
				this.inserPramList("subject=" + HttpUtility.UrlEncode(subject, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(body))
			{
				this.inserPramList("body=" + body, arrayList);
				this.inserPramList("body=" + HttpUtility.UrlEncode(body, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(payment_type))
			{
				this.inserPramList("payment_type=" + payment_type, arrayList);
				this.inserPramList("payment_type=" + payment_type, arrayList2);
			}
			if (!string.IsNullOrEmpty(total_fee))
			{
				this.inserPramList("price=" + total_fee, arrayList);
				this.inserPramList("price=" + total_fee, arrayList2);
			}
			if (!string.IsNullOrEmpty(show_url))
			{
				this.inserPramList("show_url=" + show_url, arrayList);
				this.inserPramList("show_url=" + HttpUtility.UrlEncode(show_url, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(seller_email))
			{
				this.inserPramList("seller_email=" + seller_email, arrayList);
				this.inserPramList("seller_email=" + HttpUtility.UrlEncode(seller_email, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(seller_id))
			{
				this.inserPramList("seller_id=" + seller_email, arrayList);
				this.inserPramList("seller_id=" + seller_id, arrayList2);
			}
			if (!string.IsNullOrEmpty(this.return_url))
			{
				this.inserPramList("return_url=" + this.return_url, arrayList);
				this.inserPramList("return_url=" + HttpUtility.UrlEncode(this.return_url, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(this._input_charset))
			{
				this.inserPramList("_input_charset=" + this._input_charset, arrayList);
				this.inserPramList("_input_charset=" + this._input_charset, arrayList2);
			}
			if (!string.IsNullOrEmpty(this.notify_url))
			{
				this.inserPramList("notify_url=" + this.notify_url, arrayList);
				this.inserPramList("notify_url=" + HttpUtility.UrlEncode(this.notify_url, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(logistics_type))
			{
				this.inserPramList("logistics_type=" + logistics_type, arrayList);
				this.inserPramList("logistics_type=" + logistics_type, arrayList2);
			}
			if (!string.IsNullOrEmpty(logistics_fee))
			{
				this.inserPramList("logistics_fee=" + logistics_fee, arrayList);
				this.inserPramList("logistics_fee=" + logistics_fee, arrayList2);
			}
			if (!string.IsNullOrEmpty(logistics_payment))
			{
				this.inserPramList("logistics_payment=" + logistics_payment, arrayList);
				this.inserPramList("logistics_payment=" + HttpUtility.UrlEncode(logistics_payment, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(quantity))
			{
				this.inserPramList("quantity=" + quantity, arrayList);
				this.inserPramList("quantity=" + quantity, arrayList2);
			}
			if (!string.IsNullOrEmpty(discount))
			{
				this.inserPramList("discount=" + discount, arrayList);
				this.inserPramList("discount=" + discount, arrayList2);
			}
			if (!string.IsNullOrEmpty(buyer_msg))
			{
				this.inserPramList("buyer_msg=" + buyer_msg, arrayList);
				this.inserPramList("buyer_msg=" + HttpUtility.UrlEncode(buyer_msg, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(buyer_email))
			{
				this.inserPramList("buyer_email=" + buyer_email, arrayList);
				this.inserPramList("buyer_email=" + HttpUtility.UrlEncode(buyer_email, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(buyer_id))
			{
				this.inserPramList("buyer_id=" + buyer_id, arrayList);
				this.inserPramList("buyer_id=" + buyer_id, arrayList2);
			}
			if (!string.IsNullOrEmpty(agent))
			{
				this.inserPramList("agent=" + agent, arrayList);
				this.inserPramList("agent=" + agent, arrayList2);
			}
			if (!string.IsNullOrEmpty(receive_name))
			{
				this.inserPramList("receive_name=" + receive_name, arrayList);
				this.inserPramList("receive_name=" + HttpUtility.UrlEncode(receive_name, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(receive_address))
			{
				this.inserPramList("receive_address=" + receive_address, arrayList);
				this.inserPramList("receive_address=" + HttpUtility.UrlEncode(receive_address, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(receive_zip))
			{
				this.inserPramList("receive_zip=" + receive_zip, arrayList);
				this.inserPramList("receive_zip=" + receive_zip, arrayList2);
			}
			if (!string.IsNullOrEmpty(receive_phone))
			{
				this.inserPramList("receive_phone=" + receive_phone, arrayList);
				this.inserPramList("receive_phone=" + receive_phone, arrayList2);
			}
			if (!string.IsNullOrEmpty(receive_mobile))
			{
				this.inserPramList("receive_mobile=" + receive_mobile, arrayList);
				this.inserPramList("receive_mobile=" + receive_mobile, arrayList2);
			}
			if (!string.IsNullOrEmpty(logistics_type_1))
			{
				this.inserPramList("logistics_type_1=" + logistics_type_1, arrayList);
				this.inserPramList("logistics_type_1=" + logistics_type_1, arrayList2);
			}
			if (!string.IsNullOrEmpty(logistics_fee_1))
			{
				this.inserPramList("logistics_fee_1=" + logistics_fee_1, arrayList);
				this.inserPramList("logistics_fee_1=" + logistics_fee_1, arrayList2);
			}
			if (!string.IsNullOrEmpty(logistics_payment_1))
			{
				this.inserPramList("logistics_payment_1=" + logistics_payment_1, arrayList);
				this.inserPramList("logistics_payment_1=" + HttpUtility.UrlEncode(logistics_payment_1, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			if (!string.IsNullOrEmpty(logistics_type_2))
			{
				this.inserPramList("logistics_type_2=" + logistics_type_2, arrayList);
				this.inserPramList("logistics_type_2=" + logistics_type_2, arrayList2);
			}
			if (!string.IsNullOrEmpty(logistics_fee_2))
			{
				this.inserPramList("logistics_fee_2=" + logistics_fee_2, arrayList);
				this.inserPramList("logistics_fee_2=" + logistics_fee_2, arrayList2);
			}
			if (!string.IsNullOrEmpty(logistics_payment_2))
			{
				this.inserPramList("logistics_payment_2=" + logistics_payment_2, arrayList);
				this.inserPramList("logistics_payment_2=" + HttpUtility.UrlEncode(logistics_payment_2, Encoding.GetEncoding(this._input_charset)), arrayList2);
			}
			string[] r = (string[])arrayList.ToArray(typeof(string));
			string[] array = AliPay.BubbleSort(r);
			string[] array2 = AliPay.BubbleSort((string[])arrayList2.ToArray(typeof(string)));
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < array.Length; i++)
			{
				if (i == array.Length - 1)
				{
					stringBuilder.Append(array[i]);
				}
				else
				{
					stringBuilder.Append(array[i] + "&");
				}
			}
			stringBuilder.Append(this.key.Trim());
			string mD = AliPay.GetMD5(stringBuilder.ToString(), this._input_charset);
			StringBuilder stringBuilder2 = new StringBuilder();
			stringBuilder2.Append(this.gateway);
			for (int i = 0; i < array2.Length; i++)
			{
				stringBuilder2.Append(array2[i] + "&");
			}
			stringBuilder2.Append("sign=" + mD + "&sign_type=" + this.sign_type);
			return stringBuilder2.ToString();
		}
	}
}
